<template>
	<div class="test-success">
		<el-row style="background:white;padding:1.5rem;">
			<el-row>
				<h1>
					{{sellerOrderInfo.serviceName}}
					<button>
						{{orderStatus(sellerOrderInfo.orderStatus)}}
					</button>
				</h1>
			</el-row>
			<el-row>
				<el-col :span='8'>
					<img :src="sellerOrderInfo.headimg" height="80" width="80" alt="avatar" style='margin:10px;'>
				</el-col>
				<el-col :span='16'>
					<div>
						<p>
							<span style='text-align:left'>用户名</span>
							{{sellerOrderInfo.nickname}}
						</p>
						<p>
							<span style='text-align:left'>订单编号</span>
							{{sellerOrderInfo.num}}
						</p>
						<p>
							<span style='text-align:left'>下单时间</span>
							{{date(sellerOrderInfo.createTime)}}
						</p>
					</div>
					<!-- <el-button 
					    v-if='sellerOrderInfo.orderStatus=="5"'
					    @click='successService(sellerOrderInfo.num)'
						style='width:65px;height:25px;float:right' 
						type='danger' >
						完成服务
					</el-button> -->
				</el-col>
			</el-row>
		</el-row>
		<button class="btn" @click="go">返回</button>
	</div>
</template>
<script>
    import { URL_GET_SELLERORINFO,AJAX,URL_ORDERSURE,URL_OREDER_SERVICE,_layer} from "@/comm.js";
	export default {
		data(){
			return ({
				sellerOrderInfo:{},
				orderGetSta:{
		          //1 3 5 可以取消订单  7 去评论  9 已取消 
		          // '1':'待支付',
		          '3':'待确认',
		          '5':'待服务',
		          '7':'已完成',
		          // '9':'已取消'
		        },
			});
		},
		created(){
			let orderNum=this.$route.query.num;
			let This=this;
			let send={orderNum:orderNum};
			$.post(URL_GET_SELLERORINFO,send,function(data){
				console.log('商户订单详情');
				console.log(data.data);
				This.sellerOrderInfo=data.data;
			});
		},
		methods:{
			go(){
				history.back();
			},
			date(timestamp){
				if(!timestamp){
					return ;
				}
				var date;
				//时间戳为10位需*1000，时间戳为13位的话不需乘1000
				if(String(timestamp).length==10){
					date=new Date(Number(timestamp) * 1000);
				}
				if(String(timestamp).length==13){
					date=new Date(Number(timestamp));
				}
		        let Y = date.getFullYear() + '-';
		        let M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
		        let D = date.getDate() + ' ';
		        let h = date.getHours() + ':';
		        let m = date.getMinutes() + ':';
		        let s = date.getSeconds();
		        return Y+M+D+h+m+s;
			},
			//根据订单状态来得到中文
		    orderStatus(status){
		      return this.orderGetSta[status];
		    },
		    // //去完成服务，进入到已完成状态
		    // successService(num){
		    // 	let send={
		    // 		orderNum:num
		    // 	};
		    // 	console.log('将进入到已完成状态');
		    // 	$.post(URL_ORDERSURE,send,function(data){
		    // 		console.log(data);
		    // 		if(data.retult){
		    // 			_layer('恭喜你，订单已完成');
		    // 			setTimeout(function(){
						// 	history.back();
		    // 			},2000);
		    // 		}else{
		    // 			_layer('确认完成服务失败  '+data.message);		    		}
		    // 	});
		    // }
		}
	}
</script>

<style scoped>
    h1,p,button{
		margin: 0;
		padding:0;
		border: none;
	}
	.test-success{
		position: absolute;
		top:0;
		bottom: 0;
		left: 0;
		right:0;
		background: #f7f7f7;
	}
	h1{
		padding-bottom: 1rem;
		border-bottom: 1px solid #efefef;
		font-family: 'Microsoft JhengHei';
		font-weight: 600;
		font-size:1.8rem;
	}
	h1 > button {
		float: right;
		padding:0.2rem 0.9rem;
		background: #f08b16;
		color:white;
	}
	p{
		margin: 1rem 0;
	}
	p span{
		display: inline-block;
		width: 5rem;
		margin-right: 1rem;
		text-align: right;
		color:#b7b7b7;
	}
	.btn{
		width: 92%;
		height:3.6rem;
		margin: 1.5rem 4%;
		background: #179ef0;
		color:white;
	}
</style>